/* ozofra 1b
 This file contains the overloaded vector
 operators '<<' and '>>'
*/

#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>

std::ostream& operator<<(std::ostream &ostr, const std::vector<int> vect)
// Prints the contents of each thing in the vector.
// No appended newline
{
  for (int idx=0; idx<vect.size(); idx++)
    ostr << vect.at(idx) <<  ' ';
  return ostr;
}

std::istream &operator>>(std::istream &istr, std::vector<int> &vect)
//operator to get guess from keyboard
//guess is in the form "1234", which 
//loads vector<int> with 1,2,3,4
{
  std::string vect_vals;
  //reset vector to contain nothing
  vect.resize(0);
  istr >> vect_vals;

  //Iterate through every char in vect_vals
  for (int idx=0; idx<vect_vals.length(); idx++)
  {

    //check if it is a number.

    //take ASCII distance from '0' (convert to int)
    int val = vect_vals.at(idx) - '0';
    vect.push_back(val);
  }
  return istr;
}

